package com.easemob.helpdesk.widget.chatrow;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.easemob.helpdesk.activity.chat.MsgShowVideoActivity;
import com.easemob.helpdesk.activity.chat.ShowVideoActivity;
import com.easemob.helpdesk.adapter.UserChatAdapter;
import com.easemob.helpdesk.bean.MsgChat;
import com.easemob.helpdesk.utils.CommonUtils;
import com.housekeeperapp.R;

/**
 * Created by wsj on 2018/6/5.
 */

public class MsgVideoViewHolder extends BaseMsgViewHolder{

    private ImageView imageView;
    private TextView sizeView;
    private TextView timeLengthView;
    private ImageView playView;
    private TextView percentageView;
    private ProgressBar pb;

    public MsgVideoViewHolder(Activity activity, UserChatAdapter chatAdapter, View itemView) {
        super(activity, chatAdapter, itemView);
    }


    @Override
    public void handleViewMessage(final MsgChat message, int position) {

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBubbleClick(message);
            }
        });

        Glide.with(activity).load("")
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE).error(R.drawable.default_image)
                .override(CommonUtils.convertDip2Px(activity, 120), CommonUtils.convertDip2Px(activity, 120))
                .into(imageView);

        pb.setVisibility(View.GONE);
        percentageView.setVisibility(View.GONE);
        if (ivStatus != null)
            ivStatus.setVisibility(View.GONE);
    }

    @Override
    protected void onFindViewById() {
        imageView = ((ImageView) findViewById(R.id.chatting_content_iv));
        sizeView = (TextView) findViewById(R.id.chatting_size_iv);
        timeLengthView = (TextView) findViewById(R.id.chatting_length_iv);
        playView = (ImageView) findViewById(R.id.chatting_status_btn);
        percentageView = (TextView) findViewById(R.id.percentage);
        pb = (ProgressBar) findViewById(R.id.progressBar);
    }

    protected void onBubbleClick(final MsgChat message) {
//        HDVideoMessageBody videoBody = (HDVideoMessageBody) message.getBody();
        Intent intent = new Intent(context, MsgShowVideoActivity.class);

//        intent.putExtra("videomsg", message);
        intent.putExtra("remoteurl", message.getUrl());
        intent.putExtra("msgid", message.getId() + message.getType());
//        intent.putExtra("secret", videoBody.getFileSecret());
//        intent.putExtra("remotepath", videoBody.getRemoteUrl());

        activity.startActivity(intent);
    }
}
